package com.kma.summer2012.client.view.mainPage.widgets;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.logical.shared.HasValueChangeHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.*;
import com.google.gwt.user.datepicker.client.DatePicker;
import com.kma.summer2012.client.presenters.mainPage.widgets.IRightSideBarPresenter;
import com.kma.summer2012.client.styles.style2.Recources;

import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: EUGENE
 * Date: 2/3/13
 * Time: 7:44 PM
 * To change this template use File | Settings | File Templates.
 */
public class RightSideBar extends Composite implements IRightSideBarPresenter.Display {
    @UiField
    protected Button createBtn;
    @UiField
    protected Button findRequestBtn;
    @UiField
    protected Button importRequestBtn;

    @UiField
    protected Button manageWorksBtn;
    @UiField
    protected Button manageToolsBtn;
    @UiField
    protected Button viewMapBtn;
    @UiField
    protected Button exportRequestsBtn;
    @UiField
    protected HorizontalPanel findRequest;
    @UiField
    protected DatePicker datePicker;
    @UiField
    protected TextBox requestId;
    @UiField
    protected FormPanel formPanel;
    @UiField
    protected FileUpload upload;

    @UiField
    protected Button closedRequestsBtn;


    interface RightSideBarUiBinder extends UiBinder<HTMLPanel, RightSideBar> {
    }

    private static RightSideBarUiBinder ourUiBinder = GWT.create(RightSideBarUiBinder.class);

    public RightSideBar() {
        HTMLPanel rootElement = ourUiBinder.createAndBindUi(this);
        setStyles();
        rootElement.add(formPanel);
        this.initWidget(rootElement);


    }

    public void setStyles() {
        createBtn.addStyleName(Recources.INSTANCE.styles().Caption());
        findRequestBtn.addStyleName(Recources.INSTANCE.styles().Caption());
        closedRequestsBtn.addStyleName(Recources.INSTANCE.styles().Caption());
        importRequestBtn.addStyleName(Recources.INSTANCE.styles().Caption());
        manageToolsBtn.addStyleName(Recources.INSTANCE.styles().Caption());
        manageWorksBtn.addStyleName(Recources.INSTANCE.styles().Caption());
        viewMapBtn.addStyleName(Recources.INSTANCE.styles().Caption());
        exportRequestsBtn.addStyleName(Recources.INSTANCE.styles().Caption());
    }

    public HasClickHandlers getCreateBtn() {
        return createBtn;
    }

    public HasClickHandlers getFindRequestBtn() {
        return findRequestBtn;
    }


    public HasClickHandlers getImportRequestBtn() {
        return importRequestBtn;
    }

    public HasClickHandlers getManageWorksBtn() {
        return manageWorksBtn;
    }

    public HasClickHandlers getManageToolsBtn() {
        return manageToolsBtn;
    }

    public HasClickHandlers getViewMapBtn() {
        return viewMapBtn;
    }

    public HasClickHandlers getExportRequestsBtn() {
        return exportRequestsBtn;
    }

    public void setDate() {
        //todo code to set date for the date picker
    }

    @Override
    public String getRequestIdToFind() {
        if (this.requestId != null)
            return this.requestId.getText();
        return "";
    }

    @Override
    public HasClickHandlers getClosedRequestsBtn() {
        return this.closedRequestsBtn;
    }

    @Override
    public HasValueChangeHandlers<Date> getDataPicker() {
        return datePicker;
    }

    @Override
    public FileUpload getFileUpload() {
        return this.upload;
    }

    @Override
    public FormPanel getFormPanel() {
        return this.formPanel;
    }


    @Override
    public void showCreateBtn(Boolean value) {
        this.createBtn.setVisible(value);
    }

    @Override
    public void showFindRequestBtn(Boolean value) {
        this.findRequest.setVisible(value);
    }

    @Override
    public void showImportRequestBtn(Boolean value) {
        this.importRequestBtn.setVisible(value);
    }

    @Override
    public void showManageWorksBtn(Boolean value) {
        this.manageWorksBtn.setVisible(value);
    }

    @Override
    public void showManageToolsBtn(Boolean value) {
        this.manageToolsBtn.setVisible(value);
    }

    @Override
    public void showViewMapBtn(Boolean value) {
        this.viewMapBtn.setVisible(value);
    }

    @Override
    public void showExportRequestsBtn(Boolean value) {
        this.exportRequestsBtn.setVisible(value);
    }

    @Override
    public void showFileUpload(Boolean value) {
        this.upload.setVisible(value);
    }

    @Override
    public void showClosedRequestBtn(Boolean value) {
        this.closedRequestsBtn.setVisible(value);
    }


}